export default {
  isPassword(pwd) {
    return /[^a-zA-Z]\w{4,15}/.test(pwd);
  },
  isPhone(val) {
    return /^1[3456789]\d{9}$/.test(val);
  },
  isEmail(val) {
    return /^[a-zA-Z0-9]+([-_.][A-Za-zd]+)*@([a-zA-Z0-9]+[-.])+[A-Za-zd]{2,5}$/.test(
      val
    );
  },
  isEmpty(val) {
    return !(val || "").toString().trim();
  },
  isURL (s) {
    return /^http[s]?:\/\/.*/.test(s)
  },
  validateURL (textval) {
    const urlregex = /^(https?|ftp):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/
    return urlregex.test(textval)
  },
  isChineseName (name) { 
    if (!/^[\u4e00-\u9fa5]{2,4}$/.test(name)) return false
    return true
  },
  alidatePwd (pwd) {
    // 至少数字、字母、特殊符号两组组合
    var regName = /(^(?![A-Z]+$)(?![a-z]+$)(?!\d+$)(?![\W_]+$)\S+$)/
    if (!regName.test(pwd)) return false
    return true
  },
  validatePwd8 (pwd) {
    var regName =  /(^(?=.*[a-zA-Z])(?=.*\d)(?=.*[~!@#$%^&*()_+`\-={}:";'<>?,./]).{8,}$)/
    if (!regName.test(pwd)) return false
    return true
  },
};
